package com.designpattern.behavior.command;

import java.util.Map;
import java.util.Set;

/**
 * @author Administration
 * @date 2021/10/21 - 13:57 - 星期四
 * @project 行为模式中的命令模式 具体命令类
 * @package com.designpattern.behavior.command
 * @by 晨
 */
public class OrderCommand implements Command {

    //持有接受者对象
    private SeniorChef receiver;
    private Order order;

    public OrderCommand(SeniorChef receiver, Order order) {
        this.receiver = receiver;
        this.order = order;
    }

    @Override
    public void execute() {
        System.out.println(order.getDiningTable() + "桌的订单：");
        Map<String, Integer> foodDic = order.getFoodDic();
        Set<String> keys = foodDic.keySet();
        for (String key : keys) {
            receiver.makeFood(order.getFoodDic().get(key),key);
        }

        try {
            Thread.sleep(10000);//停顿一下 模拟做饭的过程
        }catch (InterruptedException e){
            e.getMessage();
        }

        System.out.println(order.getDiningTable() + "桌的饭弄好了");
    }
}
